package com.haixin.security.service.impl;

import com.haixin.security.dao.UserRoleMapper;
import com.haixin.security.bean.UserRole;
import com.haixin.security.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public List<UserRole> getAllUserRoles() {
        return userRoleMapper.getAllUserRoles();
    }

    @Override
    public List<Integer> getRolesByUserId(int userId) {
        return userRoleMapper.getRolesByUserId(userId);
    }

    @Override
    public boolean addUserRole(UserRole userRole) {
        return userRoleMapper.insertUserRole(userRole) > 0;
    }

    @Override
    public boolean removeUserRolesByUserId(int userId) {
        return userRoleMapper.deleteUserRolesByUserId(userId) > 0;
    }

    @Override
    public boolean removeUserRole(UserRole userRole) {
        return userRoleMapper.deleteUserRole(userRole) > 0;
    }
}
